package com.design.代理模式.m2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class TestMain {

	public static void main(String[] args) {
		
		Singer target = new Singer();
		ISinger proxy = (ISinger) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new InvocationHandler() {
			
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				System.out.println("方法开始执行");
				Object obj = method.invoke(target, args);
				System.out.println("方法执行结束");
				return obj;
			}
		});
		
		proxy.sing();
		
	}
	
}
